<template>
	<view>
		<view class="list">
			<view class="item" v-for="(item,index) in list" :key="index">
				<view class="item_l">
					<view class="item_name">编码: {{item.code}}</view>
					<view class="item_time">{{item.createtime}}</view>
				</view>
				<view class="item_r" style="color: #41644A;" v-if="item.status==0">
					未开奖
				</view>
				<view class="item_r" style="color: #41644A;" v-if="item.status==1">
					已中奖
				</view>
				<view class="item_r" v-if="item.status==2">
					未中奖
				</view>
			</view>
			<view class="flex-center addressImgBox" v-if="list.length==0">
				<image src="https://wx.2024csnl.com/static/noData.png"></image>
				暂无数据~
			</view>
			<view style="text-align: center;color: #999;" v-if="noMoreData&&list.length!=0">没有更多啦~</view>
			<view style="height: 50px;"></view>
		</view>
	</view>
</template>

<script>
	import {
		getParticipationRecord
	} from "../../api/index.js"
	export default {
		data() {
			return {
				list: [1],
				pagenum: 1,
				totalPage: '',
				noMoreData: false,
			}
		},
		onLoad() {
			this.getParticipationRecordList()
		},
		onBackPress() {
			uni.$emit('recordBack', 1);
		},

		onReachBottom() {
			this.pagenum += 1
			this.getParticipationRecordList('bottom')
		},
		methods: {
			async getParticipationRecordList(type) {
				const res = await getParticipationRecord(`s=/ApiChoujiang/joinrecord&pagenum=${this.pagenum}`)
				const {
					msg,
					data,
					status,
				} = res.data
				// console.log(res, "res", data)
				if (status == 1) {
					type == 'bottom' ? this.list.push(...data) : this.list = data
					this.pagenum != 1 && data.length == 0 ? this.noMoreData = true : this.noMoreData = false

				} else {
					this.showToast(msg)
				}
			},

		}
	}
</script>

<style lang="scss" scoped>
	.item_r {
		color: #999;
	}

	.addressImgBox {
		flex-direction: column;
		color: #999;
		padding-top: 20%;

		image {
			width: 400rpx;
			height: 400rpx;
		}
	}

	.list {
		.item {
			padding: 28upx 52upx 28upx 30upx;
			box-sizing: border-box;
			border-radius: 10upx;
			display: flex;
			justify-content: space-between;
			align-items: center;
			background-color: #fff;
			margin-bottom: 20upx;
			border-bottom: 1px solid #F5F5F5;

			.item_l {
				.item_name {
					color: #333333;

					font-size: 30rpx;
					line-height: 28upx;
					font-weight: 400;
					margin-bottom: 30rpx;
				}

				.item_time {
					font-size: 26upx;
					line-height: 26upx;
					color: #B3B3B3;
				}
			}
		}
	}
</style>
